package com.example.train_operate.controller;


import com.example.train_operate.entity.Instruction;
import com.example.train_operate.service.InstructionService;
import com.example.train_operate.util.Result;
import io.swagger.annotations.Api;

import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@CrossOrigin
@Api(tags = "故障判断指导书接口")
@RequestMapping("/FaultDiagnosisInstruction")
public class InstructionController {
    @Resource
    private InstructionService instructionService;

@PostMapping("/addInstruction")
public Result addInstruction(@RequestBody Instruction instruction){
    return instructionService.addInstruction(instruction);
}

    @PutMapping("/updateInstruction")
    public Result updateInstruction(@RequestBody Instruction instruction){
        return instructionService.updateInstruction(instruction);
    }

    @DeleteMapping("/deleteInstruction")
    public Result deleteInstruction(@RequestParam Integer instructionId){
        return instructionService.deleteInstruction(instructionId);
    }

    @GetMapping("/getInstructionById")
    public Result getInstructionById(@RequestParam Integer instructionId){
        return instructionService.getInstructionById(instructionId);
    }

    @GetMapping("/getAllInstruction")
    public Result getAllInstruction(){
        return Result.ok(instructionService.list());
    }

}
